﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tools.EventObjectMoudle
{
    internal class _EventObjectValues
    {
        public void Set(object[] values)
        {
            this._Values = values;
        }

        public int Count
        {
            get
            {
                return (this._Values != null) ? this._Values.Length : 0;
            }
        }

        public T GetValue<T>(int idx)
        {
            T result;
            if (idx < 0 || idx >= this.Count)
            {
                result = default(T);
            }
            else
            {
                result = (T)((object)this._Values[idx]);
            }
            return result;
        }

        private object[] _Values = null;
    }

    public class EventObject
    {
        public EventObject(int eventType) : this(eventType, null)
        {
        }

        public EventObject(int eventType, params object[] args)
        {
            this.eventType = eventType;
            this._Args.Set(args);
        }

        public int getEventType()
        {
            return this.eventType;
        }

        public void SetArgs(params object[] args)
        {
            this._Args.Set(args);
        }

        public int ArgsCount
        {
            get
            {
                return this._Args.Count;
            }
        }

        public T GetArgs<T>(int idx)
        {
            return this._Args.GetValue<T>(idx);
        }

        public void SetResults(params object[] results)
        {
            this._Results.Set(results);
        }

        public int ResultsCount
        {
            get
            {
                return this._Results.Count;
            }
        }

        public T GetResults<T>(int idx)
        {
            return this._Results.GetValue<T>(idx);
        }

        private int eventType = -1;

        private _EventObjectValues _Args = new _EventObjectValues();

        private _EventObjectValues _Results = new _EventObjectValues();

        public bool TriggerNext = true;
    }
}
